home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Macromedia Multimedia Showcase 5.1
/
Macromedia - Multimedia Showcase 5.1 (Macromedia) (1996).ISO
/
pc
/
media
/
shared.dir
/
02019_Script_Finder Object
< prev
next >
Wrap
Text File
|
1996-03-28
|
5KB
|
168 lines
-- script for "Finder Object"
property scrollUpButtonSprite, scrollDownButtonSprite, whichFinder, prefixField, addrField, ¼
currentAddrList, currentPrefix, currentFieldValue, currentAddrNum
global gNavObj
on birth me, finderType
-- The scroll up and down button scripts are added dynamically
global sBirthPtr, tBirthPtr, sDeathPtr, tDeathPtr, castIdPtr, scriptPtr
set whichFinder = finderType -- #ATP or #MAGIC
set prefixField = "prefix"
set addrField = "Finder Result"
set buttonList = [ "bUp", "bDown" ]
set scriptList = [ "findPrevAddress", "findNextAddress" ]
set scrollUpButtonSprite = 30
set scrollDownButtonSprite = 31
set myEvent = string( the curEvent of gNavObj )
set birthScene = item sBirthPtr of myEvent
put birthScene into item sDeathPtr of myEvent
put "end" into item tDeathPtr of myEvent
repeat with buttonNum = 1 to count(buttonList)
put getAt(buttonList,buttonNum) into item castIdPtr of myEvent
put getAt(scriptList,buttonNum) into item scriptPtr of myEvent
-- put "in finder object"
DrawBtn (gNavObj, myEvent, "#AddFinderObj")
end repeat
set currentPrefix = "415"
put currentPrefix into field prefixField
set currentFieldValue = currentPrefix
setAddrList(me, currentPrefix)
set currentAddrNum = 1
getAddress(me)
return me
end birth
--
on kill me
put " " into field prefixField
set the textSize of field prefixField = 18
set the textStyle of field prefixField to "bold"
put " " into field addrField
set the textSize of field addrField = 12
set the textStyle of field addrField to "plain"
end kill
--
on getAddress me
if currentAddrList = [ ] then return
set addrInfo = getAt(currentAddrList, currentAddrNum)
if whichFinder = "#ATP" or whichFinder = #ATP then
set layout = [ [1], [2,", ",3,", ",4], ["(",5,") ",6], [7] ]
else
set layout = [ [1], [2], [3,", ",4," ",5], [6] ]
end if
set thisAddr = ""
repeat with lineList in layout
set thisLine = ""
set itemsInLine = count(lineList)
repeat with i = 1 to itemsInLine
set whichItem = getAt(lineList,i)
if stringP(whichItem) then put whichItem after thisLine
else put getAt(addrInfo, whichItem) after thisLine
if i = itemsInLine then put RETURN after thisLine
end repeat
put thisLine after thisAddr
end repeat
delete line (the number of lines of thisAddr) of thisAddr
put thisAddr into field addrField
end getAddress
--
on setAddrList me, aPrefix
if whichFinder = #ATP or whichFinder = "#ATP" then
set wholeList = value(field "ATP list")
set aPrefix = value(aPrefix)
else
-- MAGIC Finder
set prefStart = value(char 1 of aPrefix)
if not( (prefStart > 1) and (prefStart <= 9) ) then return 0
set theField = "MAGIC " & prefStart & "xx"
set wholeList = value(field theField)
end if
set newList = getAProp(wholeList, aPrefix)
if voidP(newList) then
set currentAddrList = [ ]
return 0
else
set currentAddrList = newList
return 1
end if
end setAddrList
--
on findPrevAddress
if objectP(the FinderObj of gNavObj) then
set me = the FinderObj of gNavObj
set totalAddresses = count(the currentAddrList of me)
if totalAddresses < 1 then return 0
set the currentAddrNum of me = (the currentAddrNum of me) - 1
if the currentAddrNum of me = 0 then set the currentAddrNum of me = totalAddresses
getAddress(the FinderObj of gNavObj)
end if
end findPrevAddress
--
on findNextAddress
if objectP(the FinderObj of gNavObj) then
set me = the FinderObj of gNavObj
set totalAddresses = count(the currentAddrList of me)
if totalAddresses < 1 then return 0
set the currentAddrNum of me = (the currentAddrNum of me) + 1
if the currentAddrNum of me > totalAddresses then set the currentAddrNum of me = 1
getAddress(the FinderObj of gNavObj)
end if
end findNextAddress
--
on selectAddr
if objectP(the FinderObj of gNavObj) then
set theField = the prefixField of (the FinderObj of gNavObj)
set numWords = the number of words of line 1 of field theField
hilite word 1 to numWords of line 1 of field theField
end if
end selectAddr
--
on checkForNewCode me
set newPrefix = field prefixField
if (the number of chars of newPrefix > 4) or (the number of lines of newPrefix > 1) then
set newPrefix = char 1 to 4 of line 1 of newPrefix
put newPrefix into field prefixField
end if
if newPrefix <> currentPrefix then
-- check if new prefix is valid
if setAddrList(me, newPrefix) > 0 then
-- new prefix returned a valid list
set currentPrefix = newPrefix
set currentAddrNum = 1
getAddress(me)
else
set len = the number of chars in newPrefix
if len = 2 then
set thisAddr = "No companies were found within that country code."
else
if len = 3 then
set thisAddr = "No companies were found within that area code."
else
set thisAddr = "You need to enter a valid area or country code."
end if
end if
set currentPrefix = newPrefix
put thisAddr into field addrField
end if
end if
end checkForNewCode